<template>
	<view>
		<view class="uni-margin-wrap">
			<swiper class="swiper" circular :autoplay="true" :interval="3000" :duration="1000" style="height:256rpx">
				<swiper-item>
					<image src="/static/imgs/Bnner1.png" style="width:750rpx;height:256rpx"></image>
					</swiper-item>
				<swiper-item>	
					<image src="/static/imgs/Bnner2.png" style="width:750rpx;height:256rpx"></image>
					
					</swiper-item>
				<!-- <swiper-item><view class="swiper-item uni-bg-green" style="background: #4CD964;">B</view></swiper-item>
				<swiper-item><view class="swiper-item uni-bg-blue" style="background: #338;">C</view></swiper-item> -->
			</swiper>
		</view>
		<view class="apps">
			<view v-for="(group, idx) in moduleGroups" :key="idx" class="group">
				<view class="group-title">
					<text>{{ group.name }}</text>
				</view>
				<view class="group-items">
					<view v-for="(module, index) in group.modules" class="group-item" @click="onModuleClick(module)">
						<view class="item-icon">
							<view class="item-icon-outer" :style="{ background: module.icon && module.icon.bg }">
								<!-- <uni-icons :type="(module.icon && module.icon.type) || 'camera-filled'"></uni-icons> -->
								<!-- <image :src="module.iconUrl" style="width:84rpx;height:84rpx;"></image> -->
								<!-- <image :src="require(module.iconUrl)" style="width:84rpx;height:84rpx;"></image> -->
								<view :class="module.iconClass + '  moduleIcon'" style="width:84rpx;height:84rpx;'"></view>
							</view>
						</view>
						<view class="item-name">
							<text>{{ module.name }}</text>
						</view>
					</view>
					<view style="clear: both;"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
const allModuleGroups = [
	{
		name: '设备点检',
		modules: [
			{
				name: '点检列表',
				desc: '点检员进行点检操作...',
				path: 'pages/equip/list?maintainType=1&confirmCode=',
				iconClass: 'shebei_shebeidianjian'
			},
			{
				name: '点检确认',
				desc: '班长对点检结果进行确认...',
				path: 'pages/equip/list?maintainType=1&confirmCode=1',
				iconClass: 'shebei_shebeidianjian_queren'
				// icon: {
				// 	bg: '#15bc83',
				// 	type: 'navigate-filled'
				// }
			},
			{
				name: '点检质检',
				desc: '质量管理对点检结果进行检验...',
				path: 'pages/equip/list?maintainType=1&confirmCode=2',
				iconClass: 'shebei_zhiliangqueren'
			}
		]
	},
	{
		name: '设备维护',
		modules: [
			{
				name: '维修列表',
				desc: '维修员进行维修操作...',
				path: 'pages/equip/list?maintainType=3&confirmCode=',
				iconClass: 'shebei_shebeiweixiu'
			},
			{
				name: '维修确认',
				desc: '班长对维修结果进行确认...',
				path: 'pages/equip/list?maintainType=3&confirmCode=1',
				iconClass: 'shebei_shebeiweixiu_queren'
			},
			{
				name: '维修质检',
				desc: '质量管理对维修结果进行检验...',
				path: 'pages/equip/list?maintainType=3&confirmCode=2',
				iconClass: 'shebei_zhiliangqueren'
			}
		]
	},
	{
		name: '设备保养',
		modules: [
			{
				name: '保养列表',
				desc: '保养员进行保养操作...',
				path: 'pages/equip/list?maintainType=2&confirmCode=',
				iconClass: 'shebei_shebeibaoyang'
			},
			{
				name: '保养确认',
				desc: '班长对保养结果进行确认...',
				path: 'pages/equip/list?maintainType=2&confirmCode=1',
				iconClass: 'shebei_shebeibaoyang_queren'
			},
			{
				name: '保养质检',
				desc: '质量管理对保养结果进行检验...',
				path: 'pages/equip/list?maintainType=2&confirmCode=2',
				iconClass: 'shebei_zhiliangqueren'
			}
		]
	},
	{
		name: '仓储管理',
		modules: [
			{
				name: '理货',
				path: 'pages/kufang/lihuo',
				iconClass: 'cangku_lihuo',
				code: 'WMSReceive'
			},
			{
				name: '上架',
				iconClass: 'cangku_shangjia',
				path: 'pages/kufang/shangjia',
				code: 'WMSPutAway'
			},
			{
				name: '储位转移',
				iconClass: 'cangku_chuweizhuanyi',
				path:'pages/kufang/chuweitiaozheng',
				code: 'WMSMove'
			},
			{
				name: '调拨',
				iconClass: 'cangku_diaobo',
				path:'pages/kufang/diaoboshaomiao',
				code: 'WMSAllocate'
			},
			{
				name: '盘点',
				iconClass: 'cangku_pandian',
				path:'pages/kufang/pandiansaomiao',
				code: 'WMSCi'
			},
			{
				name: '下架',
				iconClass: 'cangku_xiajia',
				path:'pages/kufang/xiajia',
				code: 'WMSPickUp'
			},
			{
				name: '工单发料',
				iconClass: 'cangku_gongdanfaliao',
				path:'pages/kufang/gongdanfaliao',
				code: 'WMSWoPickUp'
			},
			{
				name:'完工入库',
				iconClass:'cangku_wangongruku',
				path:'pages/kufang/wangongruku',
				code:'WMSWoPickUp'
			},
			{
				name:'成品发货',
				iconClass:'cangku_xiaoshouchuku',
				path:'pages/kufang/chengpinfahuo',
				code:'WMSWoPickUp'
			},
			{
				name:'初始化库存',
				iconClass:'cangku_chushihuakucun',
				path:'pages/kufang/chushihuakucun',
				code:'WMSInitInventory'
			}
		]
	},
	{
		name: '生产管理',
		modules: [
			{
				name: '产线投料',
				path: 'pages/equip/checkList',
				iconClass: 'shengchan_chanxiantouliao'
			},
			{
				name: 'SMT上料',
				iconClass: 'shengchan_SMTshangliao'
			},
			{
				name: 'SMT接料',
				iconClass: 'shengchan_SMTjieliao'
			},
			{
				name: '生产送检',
				iconClass: 'shengchan_shengchansongjian'
			}
		]
	}
];

export default {
	data() {
		return {
			bannerList: [
				{
					image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
					title: '昨夜星辰昨夜风，画楼西畔桂堂东'
				},
				{
					image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
					title: '身无彩凤双飞翼，心有灵犀一点通'
				},
				{
					image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
					title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
				}
			],
			moduleGroups: []
		};
	},
	methods: {
		onModuleClick(module) {
			uni.navigateTo({
				url: '../../' + module.path
			});
		}
	},
	mounted() {
		const userModules = getApp().globalData.modules.filter(x => !x.isParent);
		var newGroup = allModuleGroups
			.map(x => {
				if(x.name.startsWith('设备')) return {
					name: x.name,
					modules: x.modules
				}
				const ms = x.modules.filter(m => userModules.findIndex(um => um.code === m.code) > -1);
				return {
					name: x.name,
					modules: ms
				};
			})
			.filter(x => x.modules.length);
		console.log(newGroup);
		this.moduleGroups.splice(0, 0, ...newGroup);
	}
};
</script>

<style lang="less">
.swiper-item {
	//	height: 400rpx;
}

.apps {
	.group {
		.group-title {
			padding: 10rpx;
			color: #888;
		}

		.group-items {
			.group-item {
				float: left;
				width: 33.33%;
				text-align: center;
				margin-bottom: 30rpx;

				.item-icon {
					.item-icon-outer {
						width: 84rpx;
						height: 84rpx;
						margin-right: 10rpx;
						text-align: center;
						display: inline-block;
						vertical-align: middle;
						line-height: 84rpx;
						// background: #007aff;
						color: #fff;
						border-radius: 20rpx;

						.uni-icons {
							color: #fff !important;
							font-size: 40rpx !important;
						}
					}
				}

				.item-name {
					color: #888;
					font-size: 0.8em;
				}
			}
		}
	}
}

.moduleIcon {
	background-size: 100%;
	background-repeat: no-repeat;
}

.shebei_shebeidianjian {
	background-image: url(/static/imgs/shebei/shebeidianjian.png);
}

.shebei_shebeidianjian_queren{
	background-image: url(/static/imgs/shebei/shebeidianjian-queren.png);
}

.shebei_confirm {
	background-image: url(/static/imgs/shebei/confirm.png);
}

.shebei_zhiliangqueren {
	background-image: url(/static/imgs/shebei/zhiliangqueren.png);
}

.shebei_shebeiweixiu {
	background-image: url(/static/imgs/shebei/shebeiweixiu.png);
}

.shebei_shebeiweixiu_queren {
	background-image: url(/static/imgs/shebei/shebeiweixiu-queren.png);
}
.shebei_banzhangqueren {
	background-image: url(/static/imgs/shebei/confirm.png);
}

.shebei_shebeibaoyang {
	background-image: url(/static/imgs/shebei/shebeibaoyang.png);
}
.shebei_shebeibaoyang_queren{
	background-image: url(/static/imgs/shebei/shebeibaoyang-queren.png);
}

.cangku_lihuo {
	background-image: url(/static/imgs/cangku/lihuo.png);
}

.cangku_shangjia {
	background-image: url(/static/imgs/cangku/shangjia.png);
}

.cangku_chuweizhuanyi {
	background-image: url(/static/imgs/cangku/chuweizhuanyi.png);
}

.cangku_diaobo {
	background-image: url(/static/imgs/cangku/diaobo.png);
}

.cangku_pandian {
	background-image: url(/static/imgs/cangku/pandian.png);
}

.cangku_xiajia {
	background-image: url(/static/imgs/cangku/xiajia.png);
}

.cangku_gongdanfaliao {
	background-image: url(/static/imgs/cangku/gongdanfaliao.png);
}

.cangku_wangongruku {
	background-image: url(/static/imgs/cangku/wangongruku.png);
}

.cangku_xiaoshouchuku {
	background-image: url(/static/imgs/cangku/xiaoshouchuku.png);
}

.shengchan_chanxiantouliao {
	background-image: url(/static/imgs/shengchan/chanxiantouliao.png);
}

.shengchan_SMTshangliao {
	background-image: url(/static/imgs/shengchan/SMTshangliao.png);
}

.shengchan_SMTjieliao {
	background-image: url(/static/imgs/shengchan/SMTjieliao.png);
}

.shengchan_shengchansongjian {
	background-image: url(/static/imgs/shengchan/shengchansongjian.png);
}
.cangku_chushihuakucun{
	background-image: url(../../static/imgs/cangku/chushihuakucun.png);
}

// .workplace-modules {
// }

// .workplace-group-title {
// 	padding: 10rpx;
// 	color: #888;
// }
// .uni-media-list-text-top {
// 	font-size: 32rpx;
// }
// .uni-media-list-text-bottom {
// 	font-size: 24rpx;
// }
// .uni-media-list-logo {
// 	height: 84rpx;
// 	width: 84rpx;
// 	margin-right: 10rpx;
// 	text-align: center;
// 	display: inline-block;
// 	vertical-align: middle;
// 	line-height: 80rpx;
// 	background: #007aff;
// 	color: #fff;
// 	border-radius: 50%;
// 	.uni-icons {
// 		color: #fff !important;
// 	}
// }
</style>
